package com.nullpointer.xchatfinal.object;

import java.util.Collection;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

public class GroupMessageContent {
	private MessageContent messageContent;
	private String fromGroupJID;
	private String fromGroupName;

	public MessageContent getMessageContent() {
		return messageContent;
	}

	public void setMessageContent(MessageContent messageContent) {
		this.messageContent = messageContent;
	}

	public String getFromGroupJID() {
		return fromGroupJID;
	}

	public void setFromGroupJID(String fromGroupJID) {
		this.fromGroupJID = fromGroupJID;
	}

	public String getFromGroupName() {
		return fromGroupName;
	}

	public void setFromGroupName(String fromGroupName) {
		this.fromGroupName = fromGroupName;
	}

	public String toJson() {
		return new JSONSerializer().exclude("*.class").deepSerialize(this);
	}

	public static GroupMessageContent fromJsonToGroupMessageContent(String json) {
		try {
			GroupMessageContent groupMessageContent = new JSONDeserializer<GroupMessageContent>()
					.use(null, GroupMessageContent.class).deserialize(json);
			return groupMessageContent;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static String toJsonArray(Collection<GroupMessageContent> collection) {
		return new JSONSerializer().exclude("*.class")
				.deepSerialize(collection);
	}

}
